package com.bawei.property.model

import com.bawei.common.entity.BaseResultEntity
import com.bawei.common.model.BaseRepository
import com.bawei.network.HttpInterceptorType
import com.bawei.property.api.PropertyApiServer
import com.bawei.property.entity.CarApplyResultEntity
import com.bawei.property.entity.CarColorResultEntity
import com.bawei.property.entity.ParkApplyResultEntity
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import okhttp3.MultipartBody
import okhttp3.RequestBody
import javax.inject.Inject

/**
 * Author: Jason Zhang
 * Date: 2024/5/29
 * Desc: 车位申请仓库
 */

class CarApplyRepository @Inject constructor() : BaseRepository<PropertyApiServer>(){

    suspend fun getCarApplyList(): CarApplyResultEntity {
        var apiServer = createApiServer(PropertyApiServer::class.java, HttpInterceptorType.TOKEN) as PropertyApiServer
        return apiServer.getParkingList()
    }

    suspend fun getParkApplyList(body: RequestBody): ParkApplyResultEntity = (createApiServer(PropertyApiServer::class.java, HttpInterceptorType.TOKEN) as PropertyApiServer).getParkApplyList(body)

    suspend fun getCarColors(): CarColorResultEntity = (createApiServer(PropertyApiServer::class.java, HttpInterceptorType.TOKEN) as PropertyApiServer).getCarColors()

    suspend fun uploadCarImageWithFlow(list: MutableList<MultipartBody.Part>): Flow<BaseResultEntity> {
        var resultEntity = (createApiServer(PropertyApiServer::class.java, HttpInterceptorType.UPLOAD) as PropertyApiServer).uploadCarImages(list)
        return flowOf(resultEntity)
    }

    suspend fun uploadCarImage(list: MutableList<MultipartBody.Part>): BaseResultEntity = (createApiServer(PropertyApiServer::class.java, HttpInterceptorType.UPLOAD) as PropertyApiServer).uploadCarImages(list)



}